
import { registerClass } from "../../../cfw/tools/class_decorator";
import BaseAd from "../../core/base/BaseAd";
import { SDKLogicState, SDKState } from "../../SDKDefine";
;

@registerClass('TTInsertAd')
export default class TTInsertAd extends BaseAd {
  hide(): void {
    throw new Error("Method not implemented.");
  }

  load(): void {
    if (this.ad) {
      this.ad.load();
    }
  }
  show(): void {
    if (this.ad) {
      this.ad.show();
    }
  }
  onClose() {
    console.log(' 插屏广告关闭')
  }

  create() {
    if (!this.ad) {
      this.ad = this.sdk.createInterstitialAd({
        adUnitId: this.adUnitID
      });
      if (this.ad) {
        this.ad.onLoad(this.getFunc(this.onLoad))
        this.ad.onError(this.getFunc(this.onError))
      }

    }

  }


  destroy() {
    if (this.ad) {
      this.ad.offLoad(this.getFunc(this.onLoad))
      this.ad.offError(this.getFunc(this.onError))
      this.ad.destroy()
      this.ad = null;
    }
  }

}
